package terra.network;

import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;

import terra.network.handler.ClientHandler;
import terra.network.handler.PacketDecoder;
import terra.network.handler.PacketEncoder;

public class PipelineFactory implements ChannelPipelineFactory{

	static Class<? extends ClientHandler> handler;
	
	@Override
	public ChannelPipeline getPipeline() throws Exception {
        ChannelPipeline pipeline = Channels.pipeline();
        pipeline.addLast("decoder", new PacketDecoder());
        pipeline.addLast("encoder", new PacketEncoder());
        pipeline.addLast("handler", handler.newInstance());
        return pipeline;
	}

	public static void setLogicHandler(Class<? extends ClientHandler> cl){
		handler = cl;
	}
}
